<template>
  <div>
    <h1>鉴定报表</h1>
    <el-alert
      v-if="del_success===1"
      title="删除成功"
      type="success">
    </el-alert>
    <div>
      <el-row :gutter="20">
        <el-col :span="18"><div>
          <el-switch
            v-model="value1"
            active-text="个人提交历史"
            inactive-text="机构提交历史"
            @change="sw">
          </el-switch>
        </div></el-col>
      </el-row>
    </div>
    <el-table
      :data="info1"
      height="360"
      border
      style="width: 100%">
      <el-table-column
        prop="bid"
        label="报表编号"
        align="center"
        width="140"
        :resizable="false">
      </el-table-column>
      <el-table-column
        prop="wid"
        label="物证编号"
        align="center"
        width="140"
        :resizable="false">
      </el-table-column>
      <el-table-column
        prop="uid"
        label="提交者编号"
        align="center"
        width="140"
        :resizable="false">
      </el-table-column>
      <el-table-column
        prop="qid"
        label="待鉴定项目编号"
        align="center"
        width="140"
        :resizable="false">
      </el-table-column>
      <el-table-column
        prop="submitdate"
        label="提交时间"
        align="center"
        width="280"
        :resizable="false">
      </el-table-column>
      <el-table-column
        prop="state"
        label="报表状态"
        align="center"
        width="220"
        :resizable="false">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "IdentifyList" ,
  data(){
    return {
      value1:true,
      id: '',
      radio1: '报表编号',
      userinfo: '',
      del_success:'',
      info1:[],
      info:{
        wid:'1'
      }
    }
  },
  beforeRouteEnter: (to, from, next) => {
    console.log('进入路由之前');//加载数据
    next(vm => {
      vm.selectinfo();
    })
  },
  beforeRouteLeave: (to, from, next) => {
    console.log('进入路由之后');
    next()
  },
  methods:{
    sw(){
      if(this.value1){
        this.axios({
          method:"post",
          headers: { 'content-type': 'application/json' },
          url: "http://evidence.frogking.cn/identifyUserController/selectIdentifyByUid",
          params:{
            token:localStorage.getItem("token_only")
          }
        }).then(res=>{
          console.log(res)
          if(res["data"]["code"]==='306'){
            this.info1=res["data"]["item"];
          }
          else if(res["data"]["code"]==='307'){
            this.info1=[];
            this.$alert('您未提交过鉴定报表', '提示', {
              confirmButtonText: '确定'
            });
          }
          else if(res["data"]["code"]==='000'){
            this.$alert('token失效', '错误提示', {
              confirmButtonText: '确定',
              callback: action => {
                this.$router.push("/login");
                localStorage.removeItem("token_only");
              }
            });
          }
          else if(res["data"]["code"]==='001'){
            this.$alert('身份不满足，禁止操作', '错误提示', {
              confirmButtonText: '确定'
            });
          }
          else if(res["data"]["code"]==='002'){
            this.$alert('权限不满足，禁止操作', '错误提示', {
              confirmButtonText: '确定'
            });
          }
        }).catch(function (error) {
          console.log(error);
        });
      }
      else{
        this.axios({
          method:"post",
          headers: { 'content-type': 'application/json' },
          url: "http://evidence.frogking.cn/identifyUserController/selectIdentifyByJidFromUid",
          params:{
            token:localStorage.getItem("token_only")
          }
        }).then(res=>{
          console.log(res)
          if(res["data"]["code"]==='306'){
            this.info1=res["data"]["item"];
          }
          else if(res["data"]["code"]==='307'){
            this.info1=[];
            this.$alert('您所在组织未提交过鉴定报表', '提示', {
              confirmButtonText: '确定'
            });
          }
          else if(res["data"]["code"]==='000'){
            this.$alert('token失效', '错误提示', {
              confirmButtonText: '确定',
              callback: action => {
                this.$router.push("/login");
                localStorage.removeItem("token_only");
              }
            });
          }
          else if(res["data"]["code"]==='001'){
            this.$alert('身份不满足，禁止操作', '错误提示', {
              confirmButtonText: '确定'
            });
          }
          else if(res["data"]["code"]==='002'){
            this.$alert('权限不满足，禁止操作', '错误提示', {
              confirmButtonText: '确定'
            });
          }
        }).catch(function (error) {
          console.log(error);
        });
      }
    },
    selectinfo: function() {
      if(this.value1){
        this.axios({
          method:"post",
          headers: { 'content-type': 'application/json' },
          url: "http://evidence.frogking.cn/identifyUserController/selectIdentifyByUid",
          params:{
            token:localStorage.getItem("token_only")
          }
        }).then(res=>{
          console.log(res)
          if(res["data"]["code"]==='306'){
            this.info1=res["data"]["item"];
          }
          else if(res["data"]["code"]==='307'){
            this.info1=[];
            this.$alert('您未提交过鉴定报表', '提示', {
              confirmButtonText: '确定'
            });
          }
          else if(res["data"]["code"]==='000'){
            this.$alert('token失效', '错误提示', {
              confirmButtonText: '确定',
              callback: action => {
                this.$router.push("/login");
                localStorage.removeItem("token_only");
              }
            });
          }
          else if(res["data"]["code"]==='001'){
            this.$alert('身份不满足，禁止操作', '错误提示', {
              confirmButtonText: '确定'
            });
          }
          else if(res["data"]["code"]==='002'){
            this.$alert('权限不满足，禁止操作', '错误提示', {
              confirmButtonText: '确定'
            });
          }
        }).catch(function (error) {
          console.log(error);
        });
      }
    },
  }
}
</script>

<style scoped>
</style>
